//
//  FDGuideCell.m
//  FastDoctor
//
//  Created by 程建良 on 16/7/11.
//  Copyright © 2016年 sc. All rights reserved.
//

#import "FDGuideCell.h"
#import "JASidePanelController.h"
#import "LeftViewController.h"
#import "HomeViewController.h"
@implementation FDGuideCell
- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        
        // MARK: - 1.添加按钮,并且监听事件
        // 1.创建按钮
        UIButton *btn = [UIButton buttonWithType:UIButtonTypeCustom];
        // 2.设置图片
        [btn setImage:[UIImage imageNamed:@"guideStart"] forState:UIControlStateNormal];
        // 3.调整大小
        [btn sizeToFit];
        // 4.添加
        [self.contentView addSubview:btn];
        // 5.监听事件
        [btn addTarget:self action:@selector(btnClick) forControlEvents:UIControlEventTouchUpInside];
        
        // 6.赋值
        _experienceBtn = btn;
        
    }
    return self;
}

- (void)btnClick {
   
    //实例化
    
    JASidePanelController* viewController = [[JASidePanelController alloc]init];
    
    //向左滑
    viewController.leftPanel = [[LeftViewController alloc]init];
    
    //向右滑
    HomeViewController *homeViewController = [[HomeViewController alloc]init];
    viewController.centerPanel = [[UINavigationController alloc]initWithRootViewController:homeViewController];

    [UIApplication sharedApplication].keyWindow.rootViewController = viewController;
}
-(void)layoutSubviews{
    [super layoutSubviews];
    self.experienceBtn.frame = CGRectMake((self.frame.size.width - self.experienceBtn.frame.size.width)*0.5, self.frame.size.height*0.85, self.experienceBtn.frame.size.width, self.experienceBtn.frame.size.height);
}
@end
